<?php
/*
分类组件
*/
class Com_app{
	
	function __construct($ainfo=null){
		$this->app = Afun_db()->model(Acan_table_app);
		$this->data = Afun_db()->model(Acan_table_app_data);
		$this->cachename = 'tag/';
	}
	//获取所有分类并缓存
	function cgdata($pid=1,$uid=""){
		$this->cache_name = $this->cg_dbname.'-'.$pid.'_'.$uid;
		$data = Afun_cache_get($this->cache_name);
		if(empty($data)){
			$data = $this->cgdatas($pid,$uid);
			Afun_cache_set($this->cache_name,$data,3600);//写入缓存
		}
		return $data;
	}
	//获取app的id
	function app_id($app){
		if(empty($app)){return false;}
		if(is_int($app)){return $app;}
		$cachename = $this->cachename.'app_id_'.$app;
		$app_id = Afun_cache_get($cachename);
		if(empty($app_id)){
			$app_id = intval($this->app->ofind("code='$app'")->id);
			Afun_cache_set($cachename,$app_id);//写入缓存
		}
		return $app_id;
	}
	//递归获取子分类(返回对象)
	function data($id){
		
	}
}

?>